Add a simple center box test
authorMatthias Clasen <mclasen@redhat.com>
Sat, 3 Jun 2017 13:08:44 +0000 (09:08 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 5 Jun 2017 01:40:20 +0000 (21:40 -0400)
Just a simple use of this widget.

tests/Makefile.am
tests/meson.build
tests/testcenterbox.c [new file with mode: 0644]

index 1c5fc315c802a405467e325904b2e64957ab0609..40fafa97ac323d3b15c867a56d202585405ae254 100644 (file)
@@ -157,6 +157,7 @@ noinst_PROGRAMS =  $(TEST_PROGS)    \
        testpopupat                     \
        testgaction                     \
        testwidgetfocus                 \
+       testcenterbox                   \
        $(NULL)
 
 if USE_X11
@@ -270,6 +271,7 @@ testtitlebar_DEPENDENCIES = $(TEST_DEPS)
 testwindowsize_DEPENDENCIES = $(TEST_DEPS)
 listmodel_DEPENDENCIES = $(TEST_DEPS)
 testwidgetfocus_DEPENDENCIES = $(TEST_DEPS)
+testcenterbox_DEPENDENCIES = $(TEST_DEPS)
 
 animated_resizing_SOURCES =    \
        animated-resizing.c     \
@@ -461,6 +463,8 @@ listmodel_SOURCES = listmodel.c
 
 testwidgetfocus_SOURCES = testwidgetfocus.c
 
+testcenterbox_SOURCES = testcenterbox.c
+
 EXTRA_DIST +=                  \
        gradient1.png           \
        testgtk.1               \
index b29c74842a1f04db8c34216c0ddc94a57e701d7d..ac0f3b67a3803c499f07e480b220c61f6f56fec1 100644 (file)
@@ -127,6 +127,8 @@ gtk_tests = [
   ['testpopup'],
   ['testpopupat'],
   ['testgaction'],
+  ['testwidgetfocus'],
+  ['testcenterbox'],
 ]
 
 if os_linux
diff --git a/tests/testcenterbox.c b/tests/testcenterbox.c
new file mode 100644 (file)
index 0000000..151d6bf
--- /dev/null
@@ -0,0 +1,36 @@
+#include <gtk/gtk.h>
+
+int
+main (int argc, char *argv[])
+{
+  GtkWidget *window;
+  GtkWidget *box;
+  GtkWidget *child;
+
+  gtk_init ();
+
+  if (g_getenv ("RTL"))
+    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  box = gtk_center_box_new ();
+  gtk_container_add (GTK_CONTAINER (window), box);
+
+  child = gtk_label_new ("Start Start Start Start Start");
+  gtk_label_set_ellipsize (GTK_LABEL (child), PANGO_ELLIPSIZE_END);
+  gtk_center_box_set_start_widget (GTK_CENTER_BOX (box), child);
+
+  child = gtk_label_new ("Center");
+  gtk_label_set_ellipsize (GTK_LABEL (child), PANGO_ELLIPSIZE_END);
+  gtk_center_box_set_center_widget (GTK_CENTER_BOX (box), child);
+
+  child = gtk_label_new ("End");
+  gtk_label_set_ellipsize (GTK_LABEL (child), PANGO_ELLIPSIZE_END);
+  gtk_center_box_set_end_widget (GTK_CENTER_BOX (box), child);
+
+  gtk_widget_show (window);
+
+  gtk_main ();
+
+  return 0;
+}